Assigning an item to an existing array in a list within a dictionary [on hold]

Posted by Rouke on Game Development See other posts from Game Development or by Rouke
Published on 2014-08-22T17:50:37Z Indexed on 2014/08/22 22:35 UTC
Read the original article Hit count: 161

I have a Dictionary declared like:

public var PoolDict : Dictionary.<String, List.<GameObject[]> >;

I made a function to add items to the list and array

function Add(key:String, obj:GameObject)
{
    if(!PoolDict.ContainsKey(key))
    {
        PoolDict[key] = new List.<GameObject[]>();
    }

    //PlaceHolder - Not what will be in final version
    PoolDict[key].Add(null);

   //Attempts - Errors- How to add to existing array?
   PoolDict[key].Add(obj);
   PoolDict[key][0].Add(obj);

}

I'd like to replace the line after //PlaceHolder with code that will assign a gameObject to an existing array in a list that's associated with a key. How could this be done?

© Game Development or respective owner

Related posts about unity

Related posts about JavaScript